package com.nbsaas.boot.marketing.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "积分规则", model = "积分规则")
@Entity
@Table(name = "bs_points_rule")
@Comment("积分规则表")
public class PointsRule extends AbstractEntity {

    @Comment("规则名称")
    @SearchItem(name = "name", key = "name", label = "规则名称")
    @FormField(title = "规则名称", sortNum = "1", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("规则编码")
    @SearchItem(name = "code", key = "code", label = "规则编码")
    @FormField(title = "规则编码", sortNum = "2", grid = true)
    @Column(length = 50, unique = true)
    private String code;

    @Comment("规则类型")
    @SearchItem(name = "type", key = "type", label = "规则类型")
    @FormField(title = "规则类型", sortNum = "3", grid = true, type = InputType.select, option = "points_record_type")
    @Column(length = 20)
    private String type;

    @Comment("触发动作")
    @FormField(title = "触发动作", sortNum = "4", grid = true)
    @Column(length = 50)
    private String action;

    @Comment("积分值")
    @FormField(title = "积分值", sortNum = "5", grid = true, type = InputType.el_input_number)
    private Integer points;

    @Comment("最低金额")
    @FormField(title = "最低金额", sortNum = "6", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal minAmount;

    @Comment("最大积分")
    @FormField(title = "最大积分", sortNum = "7", grid = true, type = InputType.el_input_number)
    private Integer maxPoints;

    @Comment("状态")
    @SearchItem(name = "status", key = "status", label = "状态")
    @FormField(title = "状态", sortNum = "8", grid = true, type = InputType.select, option = "coupon_status")
    @Column(length = 20)
    private String status;

    @Comment("规则描述")
    @FormField(title = "规则描述", sortNum = "9", type = InputType.textarea, col = 23)
    @Column(columnDefinition = "text")
    private String description;
} 